package cn.smxy.admin.controller;

import cn.smxy.admin.aop.log.Log;
import cn.smxy.admin.service.CollegeService;
import cn.smxy.param.CollegePlantPageParam;
import cn.smxy.param.CollegeSearchParam;
import cn.smxy.pojo.College;
import cn.smxy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/college")
public class CollegeController {

    @Autowired
    private CollegeService collegeService;

    /**
     * 分页展示学校接口
     * @param collegeSearchParam 分页参数
     * @return
     */
    @GetMapping("/page")
    @Log(name = "分页展示学校")
    public R page(CollegeSearchParam collegeSearchParam){
        return collegeService.page(collegeSearchParam);
    }

    /**
     * 添加新学校接口
     * @param college
     * @return
     */
    @PostMapping("/save")
    public R save(College college){
        return collegeService.save(college);
    }

    /**
     * 删除学校接口
     * @param collegeId
     * @return
     */
    @PostMapping("/remove/{collegeId}")
    public R remove(@PathVariable("collegeId") Long collegeId){
        return collegeService.remove(collegeId);
    }

    /**
     * 修改学校信息接口
     * @param college
     * @return
     */
    @PostMapping("/update")
    public R update(College college){
        return collegeService.update(college);
    }

    /**
     * 分页展示校园作品接口
     * @param collegePlantPageParam 分页参数
     * @return
     */
    @GetMapping("/plant/page")
    public R plantPage(CollegePlantPageParam collegePlantPageParam){
        return collegeService.plantPage(collegePlantPageParam);
    }

    /**
     * 删除校园作品接口
     * @param plantId
     * @return
     */
    @PostMapping("/plant/remove/{plantId}")
    public R plantRemove(@PathVariable Long plantId){
        return collegeService.plantRemove(plantId);
    }
}
